package io.rong.imkit.widget

import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import androidx.core.view.isVisible
import io.rong.imkit.R

class NewTitleBar : FrameLayout {

    var mContext: Context? = null
    var ivBack: ImageView? = null
    var ivMore: ImageView? = null
    var tvUserImg: ImageView? = null
    var tvUserName: TextView? = null
    var tvSubTitle: TextView? = null

    constructor(context: Context) : this(context = context, null)
    constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
        this.mContext = context
        initView(attrs)
    }

    @SuppressLint("MissingInflatedId")
    private fun initView(attrs: AttributeSet?) {
        val view = LayoutInflater.from(mContext).inflate(R.layout.view_new_title_bar, this)
        val obtainStyledAttributes =
            context.obtainStyledAttributes(attrs, R.styleable.NewTitleBar)

        ivBack = view.findViewById(R.id.ivBack)
        ivMore = view.findViewById(R.id.ivMore)
        tvUserImg = view.findViewById(R.id.tvUserImg)
        tvUserName = view.findViewById(R.id.tvUserName)
        tvSubTitle = view.findViewById(R.id.tvSubTitle)
        ivMore?.isVisible = obtainStyledAttributes.getBoolean(R.styleable.NewTitleBar_more_visible,true)
    }

}